In my project that I developed with node js, I get the error "TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be string. Received undefined". Can you help me?
some of the codes:
router.post('/test', (req,res) =>{
const post_image = req.files.post_image.name
post_image.mv(path.resolve(__dirname, '../public/img/postimages', post_image.name))
Post.create(req.body)
console.log(req.files.post_image.name)
res.redirect("/")
})
I think the error may be caused by the code in third line because when you make it a comment line, the error disappears.
_dirname or post_image.name must be undefined. Check all the arguments of path.resolve() function are defined and string